<template>
	<view class="page">
		<cu-custom bgColor="bg-system-blue">
			<block style="font-size: 22px;" slot="content">哈密市智慧消防</block>
		</cu-custom>
		<view class="banner"></view>
		<view class="content-box">
		
			<view class="my-card">
					<view class="line"></view>
					<view class="my-card-box">

				<view v-if="hasTask" style="width: 100%;">
					<view class="nocomplete"  >
							<text class="cuIcon-daiwancheng"></text>
						待完成任务
					</view>
					<view class="title_body">
						<text class="title">{{ task.title }}</text>
					</view>
					<view class="task-content">
						<view class="card-content">
							<text class="text-card-title">所属企业：</text>
							<text class="text-card-info">{{ task.enterpriseName }}</text>
						</view>
						<view class="card-content">
							<text class="text-card-title">执行时间：</text>
							<text class="text-card-info">{{ task.addTime }}</text>
						</view>
						<view>
							<button @click="see_detail(task.ucId)" class="cu-btn round my-btn handle">立即处理</button>
						</view>
					</view>
				</view>
				<view class="notask" v-else>
						<view class="nocomplete"  >
						暂无任务
					</view>
					<view class="title_body">
					</view>
					</view>
					</view>

			</view>

			<view class="utools">
				<text class="utools-title">任务管理</text>
				<view class="uk">
					<view style="" class="bg-1" @click="wbgd">
						<p class="title-text"><text class="cuIcon-weibaogongdan icon"></text></p>
						<p><text>维保工单</text></p>
					</view>
					<view style="" class="bg-2" @click="wbrw">
						<p class="title-text"><text class="cuIcon-weibaorenwu icon"></text></p>
						<p><text>维保任务</text></p>
					</view>
				</view>
			</view>
		</view>
		<message />
	</view>
</template>

<script>
export default {
	created() {
		console.info("chome create")

		this.getTask()

		let that = this
		uni.$on('refreshPage', function () {
			that.getTask()
		})

	},
	data() {
		return {
			hasTask: true,
			task: ''
		}
	},
	methods: {
		getTask() {
			let that = this
			let params = {
				"pageNum": 1,
				"pageSize": 1
			}
			// 请求数据
			let app = getApp()
			app.globalData.request({
				url: 'wx/maintenance/getInMaintenanceInfoPage',
				data: params
			}).then(function (res) {
				if (res.data.data.list.length > 0) {
					that.hasTask = true
					that.task = res.data.data.list[0]
				} else {
					that.hasTask = false
				}

			}).catch(function (e) {
				that.hasTask = false
			})
		},
		wbgd() {
			uni.navigateTo({
				url: '/wb/wbgdlb/wbgdlb'
			})
		},
		wbrw() {
			uni.navigateTo({
				url: '/wb/wbrw/wbrw'
			})
		},
		see_detail(ucId) {
			uni.navigateTo({
				url: '/wb/wbxq/wbxq?ucId=' + ucId
			})
		}
	}
}
</script>

<style scoped>
.page {
	/* margin: 0 24rpx;
	margin-top: 39rpx; */
	height: 400px;
}

.my-btn {
	float: right;
	font-size: 24rpx;
	color: #458DF5;
	height: 50rpx;
}



.utools {
	margin-top: 40upx;
}

.utools-title {
	font-size: 32rpx;
	color: #333333;
	font-weight: 600;
}

.uk {
	display: flex;
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	margin-top: 20upx;
}

.uk view {
	width: 45%;
	/* height: 190upx; */
	border-radius: 8px;
}

.uk text {
	font-size: 28rpx;
	color: #333333;
	font-weight: 600;
}

.bg-1 {
	display: flex;
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	width: 180px;
	height: 60px;
	line-height: 60px;
	border-radius: 8px;
	background: linear-gradient(90deg, rgba(122, 236, 254, 0.65) 0%, rgba(122, 236, 254, 0.65) 0%, rgba(122, 185, 254, 0.65) 99%, rgba(122, 185, 254, 0.65) 99%);
}

.bg-2 {
	display: flex;
	flex-direction: row;
	justify-content: space-around;
	align-items: center;
	width: 180px;
	height: 60px;
	line-height: 60px;
	border-radius: 8px;
	background: linear-gradient(90deg, rgba(255, 202, 108, 0.65) 0%, rgba(255, 202, 108, 0.65) 0%, rgba(252, 170, 25, 0.65) 99%, rgba(252, 170, 25, 0.65) 99%);
}

.icon {
	color: rgba(255, 255, 255, 0.8) !important;
	font-size: 50px !important;
}

.title-text {
	width: 100%;
	height: 100%;
	overflow: hidden;
	text-align: center;
}



</style>
